﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Text1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            double p, r, n, s;
            {
                try
                {
                    p = Single.Parse(textBox1.Text);
                }
                catch (System.FormatException)
                {
                    MessageBox.Show("请输入本金");
                    return;
                }
                catch (System.OverflowException)
                {
                    MessageBox.Show("本金");
                    return;
                }

                try
                {
                    r = Single.Parse(textBox2.Text);
                }
                catch (System.FormatException)
                {
                    MessageBox.Show("请输入利率");
                    return;
                }
                catch (System.OverflowException)
                {
                    MessageBox.Show ("利率");
                    return;
                }

                try
                {
                    n = Single.Parse(textBox3.Text);
                }
                catch (System.FormatException)
                {
                    MessageBox.Show("请输入年份");
                    return;
                }
                catch (System.OverflowException)
                {
                    MessageBox.Show("年份");
                    return;
                }

                try
                {
                    s = p * Math.Pow(1 + r, n);
                }
                catch (System.OverflowException)
                {
                    MessageBox.Show("总额");
                    return;
                }
                textBox4.Text = s.ToString();

            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
        }
    }
}
